#ifndef UTILS_H
#define UTILS_H

class Timera
{
public:
    Timera() : beg_(clock_::now())
    {}
    
    void reset()
    {
        beg_ = clock_::now();
    }

    double elapsed() const
    {
        return std::chrono::duration_cast<second_>(clock_::now() - beg_).count();
    }

    void out(std::string message = "", int sensor = 0)
    {
        double t = elapsed();
        std::cout << message << " elapsed time: " << t << " ms" << std::endl;
        // LOG_I("{} sensor: {} elapse time {} ms", message, sensor, t);
        reset();
    }

    void out3(std::string message = "", int sensor = 0, long long ai_time = 0, long long li_time = 0)
    {
        double t = elapsed();
        // std::cout << message << " elapsed time: " << t << " ms" << std::endl;
        reset();
    }

    void out4(std::string message = "",int sensor = 0, bool bcloseBndry = false)
    {
        double t = elapsed();
        // std::cout << message << " elapsed time: " << t << " ms" << std::endl;
        int flagb = !bcloseBndry;
        reset();
    }

    double get_duration() const
    {
        return elapsed();
    }

private:
    typedef std::chrono::high_resolution_clock clock_;
    typedef std::chrono::duration<double, std::milli> second_;
    std::chrono::time_point<clock_> beg_;
};

#endif